import { menu } from '../../../app/decorator';

const { ccclass } = cc._decorator;

@ccclass
@menu(__filename, '适配限制')
export default class WidgetLimit extends cc.Component {
    onLoad() {
        const widget = this.node.getComponent(cc.Widget);

        if (!widget) return;

        const designResolution = cc.Canvas.instance.designResolution;
        const fitWidth = cc.Canvas.instance.fitWidth;
        const fitHeight = cc.Canvas.instance.fitHeight;

        if (fitWidth && fitHeight) {
            0;
        } else if (fitWidth) {
            widget.enabled = cc.winSize.height > designResolution.height;
        } else if (fitHeight) {
            widget.enabled = cc.winSize.width > designResolution.width;
        } else {
            0;
        }
    }
}
